package com.example.demo;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class testController {

    //直接使用http://localhost:8080/demo/sa 就可以访问到
    @RequestMapping(value = "/say")
    public ModelAndView say(){
        ModelAndView mv = new ModelAndView();
        mv.addObject("message","hello,spring");
        mv.setViewName("say");

        return mv;
    }

    //使用string返回
    @RequestMapping(value = "/sa")
    public String sa(Model model){

        model.addAttribute("message","hello1");
        return "say";
    }

}
